dataset <- read.delim("~/Desktop/dataset.s010")
library("imputeTS")
library("MyPackage")
library("zoo")
library("varhandle")
library("hydroGOF")
library("FSMUMI")
library("MLmetrics")
imputeTS package; linear; 5 Missing Value (smooth)
cleandata = clean(dataset)
data = aList(cleandata)
impuGV <- naInsert(data[[4]])
t <- impuGV[,1]
x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_smooth = index(x0_smooth)
trueValue_smooth <- x_smooth[c(131:135)]
x_smooth[c(131:135)] <- NA
y_smooth[c(131:135)] <- NA
id.na <- which(is.na(x_smooth))
fit1_smooth <- na_interpolation(x_smooth, option = "linear", maxgap = Inf)
imputedValue1_smooth <- fit1_smooth[131:135]
tv1_smooth <- vector()
iv1_smooth <- vector()
sum1_smooth = 0
for (i in 1:5) {
tv1_smooth[i] = as.numeric(trueValue_smooth[i])
iv1_smooth[i] = as.numeric(imputedValue1_smooth[i])
sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i])
}
mad1_smooth = sum1_smooth/5
rmse1_smooth = rmse(tv1_smooth,iv1_smooth)
mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100
ioa1_smooth = d(iv1_smooth,tv1_smooth)
fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F)
a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth)
a
## [,1]
## mad1_smooth 1.800000000
## rmse1_smooth 2.489979920
## mape1_smooth 1.576135803
## ioa1_smooth 0.537313433
## fb1_smooth 0.008583691
#plot
plot(x0_smooth, col = "grey", main = "na_interpolation linear", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_smooth)
points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19)
points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; linear; 5 Missing Value (peak)
x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_peak = index(x0_peak)
trueValue_peak <- x_peak[c(157:161)]
x_peak[c(157:161)] <- NA
y_peak[c(157:161)] <- NA
id.na <- which(is.na(x_peak))
fit1_peak <- na_interpolation(x_peak, option = "linear", maxgap = Inf)
imputedValue1_peak <- fit1_peak[157:161]
tv1_peak <- vector()
iv1_peak <- vector()
sum1_peak = 0
for (i in 1:5) {
tv1_peak[i] = as.numeric(trueValue_peak[i])
iv1_peak[i] = as.numeric(imputedValue1_peak[i])
sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i])
}
mad1_peak = sum1_peak/5
rmse1_peak = rmse(tv1_peak,iv1_peak)
mape1_peak = MAPE(iv1_peak,tv1_peak)*100
ioa1_peak = d(iv1_peak,tv1_peak)
fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F)
b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak)
b
## [,1]
## mad1_peak 4.43333333
## rmse1_peak 4.99054662
## mape1_peak 3.34202815
## ioa1_peak 0.55638985
## fb1_peak 0.02860456
#plot
plot(x0_peak, col = "grey", main = "na_interpolation linear", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_peak)
points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19)
points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; linear; 5 Missing Value (bottom)
x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_bottom = index(x0_bottom)
trueValue_bottom <- x_bottom[c(235:239)]
x_bottom[c(235:239)] <- NA
y_bottom[c(235:239)] <- NA
id.na <- which(is.na(x_bottom))
fit1_bottom <- na_interpolation(x_bottom, option = "linear", maxgap = Inf)
imputedValue1_bottom <- fit1_bottom[235:239]
tv1_bottom <- vector()
iv1_bottom <- vector()
sum1_bottom = 0
for (i in 1:5) {
tv1_bottom[i] = as.numeric(trueValue_bottom[i])
iv1_bottom[i] = as.numeric(imputedValue1_bottom[i])
sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i])
}
mad1_bottom = sum1_bottom/5
rmse1_bottom = rmse(tv1_bottom,iv1_bottom)
mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100
ioa1_bottom = d(iv1_bottom,tv1_bottom)
fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F)
c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom)
c
## [,1]
## mad1_bottom 5.26666667
## rmse1_bottom 6.15539510
## mape1_bottom 7.50804638
## ioa1_bottom 0.44299249
## fb1_bottom 0.06711409
#plot
plot(x0_bottom, col = "grey", main = "na_interpolation linear", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_bottom)
points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19)
points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputation summary table for na_interpolation(linear)
mad1_5missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3
rmse1_5missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3
mape1_5missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3
ioa1_5missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3
fb1_5missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3
st1_5missing = rbind(mad1_5missing, rmse1_5missing, mape1_5missing, ioa1_5missing, fb1_5missing)
st1_5missing
## [,1]
## mad1_5missing 3.83333333
## rmse1_5missing 4.54530721
## mape1_5missing 3.69118635
## ioa1_5missing 0.51223192
## fb1_5missing 0.04760396
imputeTS package; linear; 10 Missing Value (smooth)
cleandata = clean(dataset)
data = aList(cleandata)
impuGV <- naInsert(data[[4]])
t <- impuGV[,1]
x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_smooth = index(x0_smooth)
trueValue_smooth <- x_smooth[c(131:140)]
x_smooth[c(131:140)] <- NA
y_smooth[c(131:140)] <- NA
id.na <- which(is.na(x_smooth))
fit1_smooth <- na_interpolation(x_smooth, option = "linear", maxgap = Inf)
imputedValue1_smooth <- fit1_smooth[131:140]
tv1_smooth <- vector()
iv1_smooth <- vector()
sum1_smooth = 0
for (i in 1:10) {
tv1_smooth[i] = as.numeric(trueValue_smooth[i])
iv1_smooth[i] = as.numeric(imputedValue1_smooth[i])
sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i])
}
mad1_smooth = sum1_smooth/10
rmse1_smooth = rmse(tv1_smooth,iv1_smooth)
mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100
ioa1_smooth = d(iv1_smooth,tv1_smooth)
fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F)
a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth)
a
## [,1]
## mad1_smooth 1.572727273
## rmse1_smooth 1.923538406
## mape1_smooth 1.338510711
## ioa1_smooth 0.692440226
## fb1_smooth 0.007695596
#plot
plot(x0_smooth, col = "grey", main = "na_interpolation linear", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_smooth)
points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19)
points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; linear; 10 Missing Value (peak)
x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_peak = index(x0_peak)
trueValue_peak <- x_peak[c(155:164)]
x_peak[c(155:164)] <- NA
y_peak[c(155:164)] <- NA
id.na <- which(is.na(x_peak))
fit1_peak <- na_interpolation(x_peak, option = "linear", maxgap = Inf)
imputedValue1_peak <- fit1_peak[155:164]
tv1_peak <- vector()
iv1_peak <- vector()
sum1_peak = 0
for (i in 1:10) {
tv1_peak[i] = as.numeric(trueValue_peak[i])
iv1_peak[i] = as.numeric(imputedValue1_peak[i])
sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i])
}
mad1_peak = sum1_peak/10
rmse1_peak = rmse(tv1_peak,iv1_peak)
mape1_peak = MAPE(iv1_peak,tv1_peak)*100
ioa1_peak = d(iv1_peak,tv1_peak)
fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F)
b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak)
b
## [,1]
## mad1_peak 13.0090909
## rmse1_peak 15.1846214
## mape1_peak 10.0162910
## ioa1_peak 0.6274580
## fb1_peak 0.1093684
#plot
plot(x0_peak, col = "grey", main = "na_interpolation linear", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_peak)
points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19)
points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; linear; 10 Missing Value (bottom)
x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_bottom = index(x0_bottom)
trueValue_bottom <- x_bottom[c(234:243)]
x_bottom[c(234:243)] <- NA
y_bottom[c(234:243)] <- NA
id.na <- which(is.na(x_bottom))
fit1_bottom <- na_interpolation(x_bottom, option = "linear", maxgap = Inf)
imputedValue1_bottom <- fit1_bottom[234:243]
tv1_bottom <- vector()
iv1_bottom <- vector()
sum1_bottom = 0
for (i in 1:10) {
tv1_bottom[i] = as.numeric(trueValue_bottom[i])
iv1_bottom[i] = as.numeric(imputedValue1_bottom[i])
sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i])
}
mad1_bottom = sum1_bottom/10
rmse1_bottom = rmse(tv1_bottom,iv1_bottom)
mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100
ioa1_bottom = d(iv1_bottom,tv1_bottom)
fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F)
c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom)
c
## [,1]
## mad1_bottom 11.5000000
## rmse1_bottom 12.5499004
## mape1_bottom 15.7432863
## ioa1_bottom 0.3745036
## fb1_bottom 0.1415385
#plot
plot(x0_bottom, col = "grey", main = "na_interpolation linear", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_bottom)
points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19)
points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputation summary table for na_interpolation(linear)
mad1_10missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3
rmse1_10missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3
mape1_10missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3
ioa1_10missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3
fb1_10missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3
st1_10missing = rbind(mad1_10missing, rmse1_10missing, mape1_10missing, ioa1_10missing, fb1_10missing)
st1_10missing
## [,1]
## mad1_10missing 8.69393939
## rmse1_10missing 9.88602007
## mape1_10missing 7.96823404
## ioa1_10missing 0.56480061
## fb1_10missing 0.09692417
imputeTS package; linear; 20 Missing Value (smooth)
cleandata = clean(dataset)
data = aList(cleandata)
impuGV <- naInsert(data[[4]])
t <- impuGV[,1]
x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_smooth = index(x0_smooth)
trueValue_smooth <- x_smooth[c(125:144)]
x_smooth[c(125:144)] <- NA
y_smooth[c(125:144)] <- NA
id.na <- which(is.na(x_smooth))
fit1_smooth <- na_interpolation(x_smooth, option = "linear", maxgap = Inf)
imputedValue1_smooth <- fit1_smooth[125:144]
tv1_smooth <- vector()
iv1_smooth <- vector()
sum1_smooth = 0
for (i in 1:20) {
tv1_smooth[i] = as.numeric(trueValue_smooth[i])
iv1_smooth[i] = as.numeric(imputedValue1_smooth[i])
sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i])
}
mad1_smooth = sum1_smooth/20
rmse1_smooth = rmse(tv1_smooth,iv1_smooth)
mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100
ioa1_smooth = d(iv1_smooth,tv1_smooth)
fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F)
a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth)
a
## [,1]
## mad1_smooth 2.49285714
## rmse1_smooth 2.93622693
## mape1_smooth 2.12572968
## ioa1_smooth 0.62503068
## fb1_smooth 0.02040373
#plot
plot(x0_smooth, col = "grey", main = "na_interpolation linear", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_smooth)
points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19)
points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; linear; 20 Missing Value (peak)
x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_peak = index(x0_peak)
trueValue_peak <- x_peak[c(150:169)]
x_peak[c(150:169)] <- NA
y_peak[c(150:169)] <- NA
id.na <- which(is.na(x_peak))
fit1_peak <- na_interpolation(x_peak, option = "linear", maxgap = Inf)
imputedValue1_peak <- fit1_peak[150:169]
tv1_peak <- vector()
iv1_peak <- vector()
sum1_peak = 0
for (i in 1:20) {
tv1_peak[i] = as.numeric(trueValue_peak[i])
iv1_peak[i] = as.numeric(imputedValue1_peak[i])
sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i])
}
mad1_peak = sum1_peak/20
rmse1_peak = rmse(tv1_peak,iv1_peak)
mape1_peak = MAPE(iv1_peak,tv1_peak)*100
ioa1_peak = d(iv1_peak,tv1_peak)
fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F)
b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak)
b
## [,1]
## mad1_peak 11.15238095
## rmse1_peak 13.71292983
## mape1_peak 9.19755984
## ioa1_peak 0.53901880
## fb1_peak 0.05419813
#plot
plot(x0_peak, col = "grey", main = "na_interpolation linear", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_peak)
points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19)
points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; linear; 20 Missing Value (bottom)
x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_bottom = index(x0_bottom)
trueValue_bottom <- x_bottom[c(230:249)]
x_bottom[c(230:249)] <- NA
y_bottom[c(230:249)] <- NA
id.na <- which(is.na(x_bottom))
fit1_bottom <- na_interpolation(x_bottom, option = "linear", maxgap = Inf)
imputedValue1_bottom <- fit1_bottom[230:249]
tv1_bottom <- vector()
iv1_bottom <- vector()
sum1_bottom = 0
for (i in 1:20) {
tv1_bottom[i] = as.numeric(trueValue_bottom[i])
iv1_bottom[i] = as.numeric(imputedValue1_bottom[i])
sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i])
}
mad1_bottom = sum1_bottom/20
rmse1_bottom = rmse(tv1_bottom,iv1_bottom)
mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100
ioa1_bottom = d(iv1_bottom,tv1_bottom)
fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F)
c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom)
c
## [,1]
## mad1_bottom 13.9547619
## rmse1_bottom 17.2794722
## mape1_bottom 18.2521674
## ioa1_bottom 0.4582264
## fb1_bottom 0.1512422
#plot
plot(x0_bottom, col = "grey", main = "na_interpolation linear", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_bottom)
points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19)
points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputation summary table for na_interpolation(linear)
mad1_20missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3
rmse1_20missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3
mape1_20missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3
ioa1_20missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3
fb1_20missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3
st1_20missing = rbind(mad1_20missing, rmse1_20missing, mape1_20missing, ioa1_20missing, fb1_20missing)
st1_20missing
## [,1]
## mad1_20missing 9.2000000
## rmse1_20missing 11.3095430
## mape1_20missing 9.5342539
## ioa1_20missing 0.5407586
## fb1_20missing 0.1076293
| imputeTS package; linear; 30 Missing Value (smooth) |
| ```r cleandata = clean(dataset) data = aList(cleandata) impuGV <- naInsert(data[[4]]) t <- impuGV[,1] x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)] t1_smooth = index(x0_smooth) |
| trueValue_smooth <- x_smooth[c(120:149)] x_smooth[c(120:149)] <- NA y_smooth[c(120:149)] <- NA id.na <- which(is.na(x_smooth)) |
| fit1_smooth <- na_interpolation(x_smooth, option = “linear”, maxgap = Inf) imputedValue1_smooth <- fit1_smooth[120:149] tv1_smooth <- vector() iv1_smooth <- vector() sum1_smooth = 0 for (i in 1:30) { tv1_smooth[i] = as.numeric(trueValue_smooth[i]) iv1_smooth[i] = as.numeric(imputedValue1_smooth[i]) sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i]) } mad1_smooth = sum1_smooth/30 rmse1_smooth = rmse(tv1_smooth,iv1_smooth) mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100 ioa1_smooth = d(iv1_smooth,tv1_smooth) fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F) a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth) a ``` |
## [,1] ## mad1_smooth 6.93870968 ## rmse1_smooth 7.70651170 ## mape1_smooth 6.00348397 ## ioa1_smooth 0.55028213 ## fb1_smooth 0.05869074 |
r #plot plot(x0_smooth, col = "grey", main = "na_interpolation linear", xlab = "DisplayTime", ylab = "GlucoseValue") lines(x_smooth) points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19) points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17) legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17)) |
| ```r x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)] t1_peak = index(x0_peak) |
| trueValue_peak <- x_peak[c(145:174)] x_peak[c(145:174)] <- NA y_peak[c(145:174)] <- NA id.na <- which(is.na(x_peak)) |
| fit1_peak <- na_interpolation(x_peak, option = “linear”, maxgap = Inf) imputedValue1_peak <- fit1_peak[145:174] tv1_peak <- vector() iv1_peak <- vector() sum1_peak = 0 for (i in 1:30) { tv1_peak[i] = as.numeric(trueValue_peak[i]) iv1_peak[i] = as.numeric(imputedValue1_peak[i]) sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i]) } mad1_peak = sum1_peak/30 rmse1_peak = rmse(tv1_peak,iv1_peak) mape1_peak = MAPE(iv1_peak,tv1_peak)*100 ioa1_peak = d(iv1_peak,tv1_peak) fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F) b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak) b ``` |
## [,1] ## mad1_peak 9.013978495 ## rmse1_peak 11.039274949 ## mape1_peak 7.871617603 ## ioa1_peak 0.269920130 ## fb1_peak 0.002053689 |
r #plot plot(x0_peak, col = "grey", main = "na_interpolation linear", xlab = "DisplayTime", ylab = "GlucoseValue") lines(x_peak) points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19) points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17) legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17)) |
| ```r x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)] t1_bottom = index(x0_bottom) |
| trueValue_bottom <- x_bottom[c(225:254)] x_bottom[c(225:254)] <- NA y_bottom[c(225:254)] <- NA id.na <- which(is.na(x_bottom)) |
| fit1_bottom <- na_interpolation(x_bottom, option = “linear”, maxgap = Inf) imputedValue1_bottom <- fit1_bottom[225:254] tv1_bottom <- vector() iv1_bottom <- vector() sum1_bottom = 0 for (i in 1:30) { tv1_bottom[i] = as.numeric(trueValue_bottom[i]) iv1_bottom[i] = as.numeric(imputedValue1_bottom[i]) sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i]) } mad1_bottom = sum1_bottom/30 rmse1_bottom = rmse(tv1_bottom,iv1_bottom) mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100 ioa1_bottom = d(iv1_bottom,tv1_bottom) fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F) c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom) c ``` |
## [,1] ## mad1_bottom 10.50537634 ## rmse1_bottom 13.27484483 ## mape1_bottom 13.16386071 ## ioa1_bottom 0.46592467 ## fb1_bottom 0.09403255 |
r #plot plot(x0_bottom, col = "grey", main = "na_interpolation linear", xlab = "DisplayTime", ylab = "GlucoseValue") lines(x_bottom) points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19) points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17) legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17)) |
r mad1_30missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3 rmse1_30missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3 mape1_30missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3 ioa1_30missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3 fb1_30missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3 st1_30missing = rbind(mad1_30missing, rmse1_30missing, mape1_30missing, ioa1_30missing, fb1_30missing) st1_30missing |
## [,1] ## mad1_30missing 8.81935484 ## rmse1_30missing 10.67354383 ## mape1_30missing 9.04998213 ## ioa1_30missing 0.42870898 ## fb1_30missing 0.08225195 |
imputeTS package; spline; 5 Missing Value (smooth)
cleandata = clean(dataset)
data = aList(cleandata)
impuGV <- naInsert(data[[4]])
t <- impuGV[,1]
x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_smooth = index(x0_smooth)
trueValue_smooth <- x_smooth[c(131:135)]
x_smooth[c(131:135)] <- NA
y_smooth[c(131:135)] <- NA
id.na <- which(is.na(x_smooth))
fit1_smooth <- na_interpolation(x_smooth, option = "spline", maxgap = Inf)
imputedValue1_smooth <- fit1_smooth[131:135]
tv1_smooth <- vector()
iv1_smooth <- vector()
sum1_smooth = 0
for (i in 1:5) {
tv1_smooth[i] = as.numeric(trueValue_smooth[i])
iv1_smooth[i] = as.numeric(imputedValue1_smooth[i])
sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i])
}
mad1_smooth = sum1_smooth/5
rmse1_smooth = rmse(tv1_smooth,iv1_smooth)
mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100
ioa1_smooth = d(iv1_smooth,tv1_smooth)
fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F)
a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth)
a
## [,1]
## mad1_smooth 3.28951320
## rmse1_smooth 4.04613613
## mape1_smooth 2.86401577
## ioa1_smooth 0.44707433
## fb1_smooth 0.01877087
#plot
plot(x0_smooth, col = "grey", main = "na_interpolation spline", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_smooth)
points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19)
points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; spline; 5 Missing Value (peak)
x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_peak = index(x0_peak)
trueValue_peak <- x_peak[c(157:161)]
x_peak[c(157:161)] <- NA
y_peak[c(157:161)] <- NA
id.na <- which(is.na(x_peak))
fit1_peak <- na_interpolation(x_peak, option = "spline", maxgap = Inf)
imputedValue1_peak <- fit1_peak[157:161]
tv1_peak <- vector()
iv1_peak <- vector()
sum1_peak = 0
for (i in 1:5) {
tv1_peak[i] = as.numeric(trueValue_peak[i])
iv1_peak[i] = as.numeric(imputedValue1_peak[i])
sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i])
}
mad1_peak = sum1_peak/5
rmse1_peak = rmse(tv1_peak,iv1_peak)
mape1_peak = MAPE(iv1_peak,tv1_peak)*100
ioa1_peak = d(iv1_peak,tv1_peak)
fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F)
b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak)
b
## [,1]
## mad1_peak 12.08821984
## rmse1_peak 13.03971197
## mape1_peak 9.26638607
## ioa1_peak 0.35266742
## fb1_peak 0.08807824
#plot
plot(x0_peak, col = "grey", main = "na_interpolation spline", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_peak)
points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19)
points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; linear; 5 Missing Value (bottom)
x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_bottom = index(x0_bottom)
trueValue_bottom <- x_bottom[c(235:239)]
x_bottom[c(235:239)] <- NA
y_bottom[c(235:239)] <- NA
id.na <- which(is.na(x_bottom))
fit1_bottom <- na_interpolation(x_bottom, option = "spline", maxgap = Inf)
imputedValue1_bottom <- fit1_bottom[235:239]
tv1_bottom <- vector()
iv1_bottom <- vector()
sum1_bottom = 0
for (i in 1:5) {
tv1_bottom[i] = as.numeric(trueValue_bottom[i])
iv1_bottom[i] = as.numeric(imputedValue1_bottom[i])
sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i])
}
mad1_bottom = sum1_bottom/5
rmse1_bottom = rmse(tv1_bottom,iv1_bottom)
mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100
ioa1_bottom = d(iv1_bottom,tv1_bottom)
fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F)
c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom)
c
## [,1]
## mad1_bottom 2.177216211
## rmse1_bottom 2.766555896
## mape1_bottom 3.080168692
## ioa1_bottom 0.691538312
## fb1_bottom 0.009765306
#plot
plot(x0_bottom, col = "grey", main = "na_interpolation spline", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_bottom)
points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19)
points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputation summary table for na_interpolation(spline)
mad2_5missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3
rmse2_5missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3
mape2_5missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3
ioa2_5missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3
fb2_5missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3
st2_5missing = rbind(mad2_5missing, rmse2_5missing, mape2_5missing, ioa2_5missing, fb2_5missing)
st2_5missing
## [,1]
## mad2_5missing 5.85164975
## rmse2_5missing 6.61746800
## mape2_5missing 4.96565258
## ioa2_5missing 0.49709335
## fb2_5missing 0.01276716
imputeTS package; spline; 10 Missing Value (smooth)
cleandata = clean(dataset)
data = aList(cleandata)
impuGV <- naInsert(data[[4]])
t <- impuGV[,1]
x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_smooth = index(x0_smooth)
trueValue_smooth <- x_smooth[c(131:140)]
x_smooth[c(131:140)] <- NA
y_smooth[c(131:140)] <- NA
id.na <- which(is.na(x_smooth))
fit1_smooth <- na_interpolation(x_smooth, option = "spline", maxgap = Inf)
imputedValue1_smooth <- fit1_smooth[131:140]
tv1_smooth <- vector()
iv1_smooth <- vector()
sum1_smooth = 0
for (i in 1:10) {
tv1_smooth[i] = as.numeric(trueValue_smooth[i])
iv1_smooth[i] = as.numeric(imputedValue1_smooth[i])
sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i])
}
mad1_smooth = sum1_smooth/10
rmse1_smooth = rmse(tv1_smooth,iv1_smooth)
mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100
ioa1_smooth = d(iv1_smooth,tv1_smooth)
fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F)
a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth)
a
## [,1]
## mad1_smooth 2.456234946
## rmse1_smooth 2.905689555
## mape1_smooth 2.098494877
## ioa1_smooth 0.699529140
## fb1_smooth 0.009025291
#plot
plot(x0_smooth, col = "grey", main = "na_interpolation spline", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_smooth)
points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19)
points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; spline; 10 Missing Value (peak)
x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_peak = index(x0_peak)
trueValue_peak <- x_peak[c(155:164)]
x_peak[c(155:164)] <- NA
y_peak[c(155:164)] <- NA
id.na <- which(is.na(x_peak))
fit1_peak <- na_interpolation(x_peak, option = "spline", maxgap = Inf)
imputedValue1_peak <- fit1_peak[155:164]
tv1_peak <- vector()
iv1_peak <- vector()
sum1_peak = 0
for (i in 1:10) {
tv1_peak[i] = as.numeric(trueValue_peak[i])
iv1_peak[i] = as.numeric(imputedValue1_peak[i])
sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i])
}
mad1_peak = sum1_peak/10
rmse1_peak = rmse(tv1_peak,iv1_peak)
mape1_peak = MAPE(iv1_peak,tv1_peak)*100
ioa1_peak = d(iv1_peak,tv1_peak)
fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F)
b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak)
b
## [,1]
## mad1_peak 4.474017223
## rmse1_peak 5.085347055
## mape1_peak 3.627474926
## ioa1_peak 0.946453176
## fb1_peak 0.004298099
#plot
plot(x0_peak, col = "grey", main = "na_interpolation spline", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_peak)
points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19)
points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; linear; 10 Missing Value (spline)
x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_bottom = index(x0_bottom)
trueValue_bottom <- x_bottom[c(234:243)]
x_bottom[c(234:243)] <- NA
y_bottom[c(234:243)] <- NA
id.na <- which(is.na(x_bottom))
fit1_bottom <- na_interpolation(x_bottom, option = "spline", maxgap = Inf)
imputedValue1_bottom <- fit1_bottom[234:243]
tv1_bottom <- vector()
iv1_bottom <- vector()
sum1_bottom = 0
for (i in 1:10) {
tv1_bottom[i] = as.numeric(trueValue_bottom[i])
iv1_bottom[i] = as.numeric(imputedValue1_bottom[i])
sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i])
}
mad1_bottom = sum1_bottom/10
rmse1_bottom = rmse(tv1_bottom,iv1_bottom)
mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100
ioa1_bottom = d(iv1_bottom,tv1_bottom)
fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F)
c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom)
c
## [,1]
## mad1_bottom 2.47103147
## rmse1_bottom 3.28088780
## mape1_bottom 3.45663570
## ioa1_bottom 0.85751396
## fb1_bottom 0.03220193
#plot
plot(x0_bottom, col = "grey", main = "na_interpolation spline", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_bottom)
points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19)
points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputation summary table for na_interpolation(spline)
mad2_10missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3
rmse2_10missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3
mape2_10missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3
ioa2_10missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3
fb2_10misssing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3
st2_10missing = rbind(mad2_10missing, rmse2_10missing, mape2_10missing, ioa2_10missing, fb2_10misssing)
st2_10missing
## [,1]
## mad2_10missing 3.13376121
## rmse2_10missing 3.75730814
## mape2_10missing 3.00228587
## ioa2_10missing 0.83449876
## fb2_10misssing 0.02447638
imputeTS package; spliner; 20 Missing Value (smooth)
cleandata = clean(dataset)
data = aList(cleandata)
impuGV <- naInsert(data[[4]])
t <- impuGV[,1]
x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_smooth = index(x0_smooth)
trueValue_smooth <- x_smooth[c(125:144)]
x_smooth[c(125:144)] <- NA
y_smooth[c(125:144)] <- NA
id.na <- which(is.na(x_smooth))
fit1_smooth <- na_interpolation(x_smooth, option = "spline", maxgap = Inf)
imputedValue1_smooth <- fit1_smooth[125:144]
tv1_smooth <- vector()
iv1_smooth <- vector()
sum1_smooth = 0
for (i in 1:20) {
tv1_smooth[i] = as.numeric(trueValue_smooth[i])
iv1_smooth[i] = as.numeric(imputedValue1_smooth[i])
sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i])
}
mad1_smooth = sum1_smooth/20
rmse1_smooth = rmse(tv1_smooth,iv1_smooth)
mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100
ioa1_smooth = d(iv1_smooth,tv1_smooth)
fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F)
a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth)
a
## [,1]
## mad1_smooth 11.59810697
## rmse1_smooth 13.23001022
## mape1_smooth 9.91392164
## ioa1_smooth 0.30028330
## fb1_smooth 0.09419811
#plot
plot(x0_smooth, col = "grey", main = "na_interpolation spline", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_smooth)
points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19)
points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; spline; 20 Missing Value (peak)
x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_peak = index(x0_peak)
trueValue_peak <- x_peak[c(150:169)]
x_peak[c(150:169)] <- NA
y_peak[c(150:169)] <- NA
id.na <- which(is.na(x_peak))
fit1_peak <- na_interpolation(x_peak, option = "spline", maxgap = Inf)
imputedValue1_peak <- fit1_peak[150:169]
tv1_peak <- vector()
iv1_peak <- vector()
sum1_peak = 0
for (i in 1:20) {
tv1_peak[i] = as.numeric(trueValue_peak[i])
iv1_peak[i] = as.numeric(imputedValue1_peak[i])
sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i])
}
mad1_peak = sum1_peak/20
rmse1_peak = rmse(tv1_peak,iv1_peak)
mape1_peak = MAPE(iv1_peak,tv1_peak)*100
ioa1_peak = d(iv1_peak,tv1_peak)
fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F)
b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak)
b
## [,1]
## mad1_peak 12.05185489
## rmse1_peak 14.55482594
## mape1_peak 10.00573527
## ioa1_peak 0.47371101
## fb1_peak 0.05658692
#plot
plot(x0_peak, col = "grey", main = "na_interpolation spline", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_peak)
points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19)
points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; spline; 20 Missing Value (bottom)
x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_bottom = index(x0_bottom)
trueValue_bottom <- x_bottom[c(230:249)]
x_bottom[c(230:249)] <- NA
y_bottom[c(230:249)] <- NA
id.na <- which(is.na(x_bottom))
fit1_bottom <- na_interpolation(x_bottom, option = "spline", maxgap = Inf)
imputedValue1_bottom <- fit1_bottom[230:249]
tv1_bottom <- vector()
iv1_bottom <- vector()
sum1_bottom = 0
for (i in 1:20) {
tv1_bottom[i] = as.numeric(trueValue_bottom[i])
iv1_bottom[i] = as.numeric(imputedValue1_bottom[i])
sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i])
}
mad1_bottom = sum1_bottom/20
rmse1_bottom = rmse(tv1_bottom,iv1_bottom)
mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100
ioa1_bottom = d(iv1_bottom,tv1_bottom)
fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F)
c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom)
c
## [,1]
## mad1_bottom 26.8256289
## rmse1_bottom 32.2171499
## mape1_bottom 34.6918407
## ioa1_bottom 0.2543898
## fb1_bottom 0.2732416
#plot
plot(x0_bottom, col = "grey", main = "na_interpolation spline", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_bottom)
points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19)
points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputation summary table for na_interpolation(spline)
mad2_20missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3
rmse2_20missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3
mape2_20missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3
ioa2_20missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3
fb2_20missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3
st2_20missing = rbind(mad2_20missing, rmse2_20missing, mape2_20missing, ioa2_20missing, fb2_20missing)
st2_20missing
## [,1]
## mad2_20missing 16.8251969
## rmse2_20missing 20.0006620
## mape2_20missing 17.3789356
## ioa2_20missing 0.3427947
## fb2_20missing 0.2135604
| imputeTS package; spline; 30 Missing Value (smooth) |
| ```r cleandata = clean(dataset) data = aList(cleandata) impuGV <- naInsert(data[[4]]) t <- impuGV[,1] x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)] t1_smooth = index(x0_smooth) |
| trueValue_smooth <- x_smooth[c(120:149)] x_smooth[c(120:149)] <- NA y_smooth[c(120:149)] <- NA id.na <- which(is.na(x_smooth)) |
| fit1_smooth <- na_interpolation(x_smooth, option = “spline”, maxgap = Inf) imputedValue1_smooth <- fit1_smooth[120:149] tv1_smooth <- vector() iv1_smooth <- vector() sum1_smooth = 0 for (i in 1:30) { tv1_smooth[i] = as.numeric(trueValue_smooth[i]) iv1_smooth[i] = as.numeric(imputedValue1_smooth[i]) sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i]) } mad1_smooth = sum1_smooth/30 rmse1_smooth = rmse(tv1_smooth,iv1_smooth) mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100 ioa1_smooth = d(iv1_smooth,tv1_smooth) fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F) a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth) a ``` |
## [,1] ## mad1_smooth 27.1152022 ## rmse1_smooth 30.8901907 ## mape1_smooth 23.5896516 ## ioa1_smooth 0.1538240 ## fb1_smooth 0.2699577 |
r #plot plot(x0_smooth, col = "grey", main = "na_interpolation spline", xlab = "DisplayTime", ylab = "GlucoseValue") lines(x_smooth) points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19) points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17) legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17)) |
| ```r x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)] t1_peak = index(x0_peak) |
| trueValue_peak <- x_peak[c(145:174)] x_peak[c(145:174)] <- NA y_peak[c(145:174)] <- NA id.na <- which(is.na(x_peak)) |
| fit1_peak <- na_interpolation(x_peak, option = “spline”, maxgap = Inf) imputedValue1_peak <- fit1_peak[145:174] tv1_peak <- vector() iv1_peak <- vector() sum1_peak = 0 for (i in 1:30) { tv1_peak[i] = as.numeric(trueValue_peak[i]) iv1_peak[i] = as.numeric(imputedValue1_peak[i]) sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i]) } mad1_peak = sum1_peak/30 rmse1_peak = rmse(tv1_peak,iv1_peak) mape1_peak = MAPE(iv1_peak,tv1_peak)*100 ioa1_peak = d(iv1_peak,tv1_peak) fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F) b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak) b ``` |
## [,1] ## mad1_peak 10.65456633 ## rmse1_peak 15.03352105 ## mape1_peak 8.71821065 ## ioa1_peak 0.58823363 ## fb1_peak 0.08202274 |
r #plot plot(x0_peak, col = "grey", main = "na_interpolation spline", xlab = "DisplayTime", ylab = "GlucoseValue") lines(x_peak) points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19) points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17) legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17)) |
| ```r x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)] t1_bottom = index(x0_bottom) |
| trueValue_bottom <- x_bottom[c(225:254)] x_bottom[c(225:254)] <- NA y_bottom[c(225:254)] <- NA id.na <- which(is.na(x_bottom)) |
| fit1_bottom <- na_interpolation(x_bottom, option = “spline”, maxgap = Inf) imputedValue1_bottom <- fit1_bottom[225:254] tv1_bottom <- vector() iv1_bottom <- vector() sum1_bottom = 0 for (i in 1:30) { tv1_bottom[i] = as.numeric(trueValue_bottom[i]) iv1_bottom[i] = as.numeric(imputedValue1_bottom[i]) sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i]) } mad1_bottom = sum1_bottom/30 rmse1_bottom = rmse(tv1_bottom,iv1_bottom) mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100 ioa1_bottom = d(iv1_bottom,tv1_bottom) fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F) c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom) c ``` |
## [,1] ## mad1_bottom 44.2394790 ## rmse1_bottom 51.2934566 ## mape1_bottom 53.2909235 ## ioa1_bottom 0.1986742 ## fb1_bottom 0.4023487 |
r #plot plot(x0_bottom, col = "grey", main = "na_interpolation spline", xlab = "DisplayTime", ylab = "GlucoseValue") lines(x_bottom) points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19) points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17) legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17)) |
r mad2_30missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3 rmse2_30missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3 mape2_30missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3 ioa2_30missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3 fb2_30missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3 st2_30missing = rbind(mad2_30missing, rmse2_30missing, mape2_30missing, ioa2_30missing, fb2_30missing) st2_30missing |
## [,1] ## mad2_30missing 27.3364158 ## rmse2_30missing 32.4057228 ## mape2_30missing 27.8671063 ## ioa2_30missing 0.3135773 ## fb2_30missing 0.3582184 |
imputeTS package; stine; 5 Missing Value (smooth)
cleandata = clean(dataset)
data = aList(cleandata)
impuGV <- naInsert(data[[4]])
t <- impuGV[,1]
x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_smooth = index(x0_smooth)
trueValue_smooth <- x_smooth[c(131:135)]
x_smooth[c(131:135)] <- NA
y_smooth[c(131:135)] <- NA
id.na <- which(is.na(x_smooth))
fit1_smooth <- na_interpolation(x_smooth, option = "stine", maxgap = Inf)
imputedValue1_smooth <- fit1_smooth[131:135]
tv1_smooth <- vector()
iv1_smooth <- vector()
sum1_smooth = 0
for (i in 1:5) {
tv1_smooth[i] = as.numeric(trueValue_smooth[i])
iv1_smooth[i] = as.numeric(imputedValue1_smooth[i])
sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i])
}
mad1_smooth = sum1_smooth/5
rmse1_smooth = rmse(tv1_smooth,iv1_smooth)
mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100
ioa1_smooth = d(iv1_smooth,tv1_smooth)
fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F)
a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth)
a
## [,1]
## mad1_smooth 2.471728478
## rmse1_smooth 2.988704007
## mape1_smooth 2.153497594
## ioa1_smooth 0.512983318
## fb1_smooth 0.008522607
#plot
plot(x0_smooth, col = "grey", main = "na_interpolation stine", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_smooth)
points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19)
points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; stine; 5 Missing Value (peak)
x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_peak = index(x0_peak)
trueValue_peak <- x_peak[c(157:161)]
x_peak[c(157:161)] <- NA
y_peak[c(157:161)] <- NA
id.na <- which(is.na(x_peak))
fit1_peak <- na_interpolation(x_peak, option = "stine", maxgap = Inf)
imputedValue1_peak <- fit1_peak[157:161]
tv1_peak <- vector()
iv1_peak <- vector()
sum1_peak = 0
for (i in 1:5) {
tv1_peak[i] = as.numeric(trueValue_peak[i])
iv1_peak[i] = as.numeric(imputedValue1_peak[i])
sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i])
}
mad1_peak = sum1_peak/5
rmse1_peak = rmse(tv1_peak,iv1_peak)
mape1_peak = MAPE(iv1_peak,tv1_peak)*100
ioa1_peak = d(iv1_peak,tv1_peak)
fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F)
b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak)
b
## [,1]
## mad1_peak 4.05638164
## rmse1_peak 4.61561587
## mape1_peak 3.06029869
## ioa1_peak 0.58523473
## fb1_peak 0.02506465
#plot
plot(x0_peak, col = "grey", main = "na_interpolation stine", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_peak)
points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19)
points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; stine; 5 Missing Value (bottom)
x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_bottom = index(x0_bottom)
trueValue_bottom <- x_bottom[c(235:239)]
x_bottom[c(235:239)] <- NA
y_bottom[c(235:239)] <- NA
id.na <- which(is.na(x_bottom))
fit1_bottom <- na_interpolation(x_bottom, option = "stine", maxgap = Inf)
imputedValue1_bottom <- fit1_bottom[235:239]
tv1_bottom <- vector()
iv1_bottom <- vector()
sum1_bottom = 0
for (i in 1:5) {
tv1_bottom[i] = as.numeric(trueValue_bottom[i])
iv1_bottom[i] = as.numeric(imputedValue1_bottom[i])
sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i])
}
mad1_bottom = sum1_bottom/5
rmse1_bottom = rmse(tv1_bottom,iv1_bottom)
mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100
ioa1_bottom = d(iv1_bottom,tv1_bottom)
fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F)
c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom)
c
## [,1]
## mad1_bottom 4.1435622
## rmse1_bottom 4.6802822
## mape1_bottom 5.8822570
## ioa1_bottom 0.5120422
## fb1_bottom 0.0436976
#plot
plot(x0_bottom, col = "grey", main = "na_interpolation stine", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_bottom)
points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19)
points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputation summary table for na_interpolation(stine)
mad3_5missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3
rmse3_5missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3
mape3_5missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3
ioa3_5missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3
fb3_5missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3
st3_5missing = rbind(mad3_5missing, rmse3_5missing, mape3_5missing, ioa3_5missing, fb3_5missing)
st3_5missing
## [,1]
## mad3_5missing 3.5572241
## rmse3_5missing 4.0948673
## mape3_5missing 3.2980261
## ioa3_5missing 0.5367534
## fb3_5missing 0.0319726
imputeTS package; stine; 10 Missing Value (smooth)
cleandata = clean(dataset)
data = aList(cleandata)
impuGV <- naInsert(data[[4]])
t <- impuGV[,1]
x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_smooth = index(x0_smooth)
trueValue_smooth <- x_smooth[c(131:140)]
x_smooth[c(131:140)] <- NA
y_smooth[c(131:140)] <- NA
id.na <- which(is.na(x_smooth))
fit1_smooth <- na_interpolation(x_smooth, option = "stine", maxgap = Inf)
imputedValue1_smooth <- fit1_smooth[131:140]
tv1_smooth <- vector()
iv1_smooth <- vector()
sum1_smooth = 0
for (i in 1:10) {
tv1_smooth[i] = as.numeric(trueValue_smooth[i])
iv1_smooth[i] = as.numeric(imputedValue1_smooth[i])
sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i])
}
mad1_smooth = sum1_smooth/10
rmse1_smooth = rmse(tv1_smooth,iv1_smooth)
mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100
ioa1_smooth = d(iv1_smooth,tv1_smooth)
fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F)
a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth)
a
## [,1]
## mad1_smooth 1.673871668
## rmse1_smooth 2.006329760
## mape1_smooth 1.426246054
## ioa1_smooth 0.757447935
## fb1_smooth 0.008077339
#plot
plot(x0_smooth, col = "grey", main = "na_interpolation stine", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_smooth)
points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19)
points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; stine; 10 Missing Value (peak)
x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_peak = index(x0_peak)
trueValue_peak <- x_peak[c(155:164)]
x_peak[c(155:164)] <- NA
y_peak[c(155:164)] <- NA
id.na <- which(is.na(x_peak))
fit1_peak <- na_interpolation(x_peak, option = "stine", maxgap = Inf)
imputedValue1_peak <- fit1_peak[155:164]
tv1_peak <- vector()
iv1_peak <- vector()
sum1_peak = 0
for (i in 1:10) {
tv1_peak[i] = as.numeric(trueValue_peak[i])
iv1_peak[i] = as.numeric(imputedValue1_peak[i])
sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i])
}
mad1_peak = sum1_peak/10
rmse1_peak = rmse(tv1_peak,iv1_peak)
mape1_peak = MAPE(iv1_peak,tv1_peak)*100
ioa1_peak = d(iv1_peak,tv1_peak)
fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F)
b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak)
b
## [,1]
## mad1_peak 10.70413033
## rmse1_peak 12.75590373
## mape1_peak 8.25961147
## ioa1_peak 0.69569131
## fb1_peak 0.08682023
#plot
plot(x0_peak, col = "grey", main = "na_interpolation stine", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_peak)
points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19)
points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; stine; 10 Missing Value (bottom)
x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_bottom = index(x0_bottom)
trueValue_bottom <- x_bottom[c(234:243)]
x_bottom[c(234:243)] <- NA
y_bottom[c(234:243)] <- NA
id.na <- which(is.na(x_bottom))
fit1_bottom <- na_interpolation(x_bottom, option = "stine", maxgap = Inf)
imputedValue1_bottom <- fit1_bottom[234:243]
tv1_bottom <- vector()
iv1_bottom <- vector()
sum1_bottom = 0
for (i in 1:10) {
tv1_bottom[i] = as.numeric(trueValue_bottom[i])
iv1_bottom[i] = as.numeric(imputedValue1_bottom[i])
sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i])
}
mad1_bottom = sum1_bottom/10
rmse1_bottom = rmse(tv1_bottom,iv1_bottom)
mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100
ioa1_bottom = d(iv1_bottom,tv1_bottom)
fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F)
c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom)
c
## [,1]
## mad1_bottom 11.3083120
## rmse1_bottom 12.3585647
## mape1_bottom 15.4848858
## ioa1_bottom 0.3791200
## fb1_bottom 0.1393436
#plot
plot(x0_bottom, col = "grey", main = "na_interpolation stine", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_bottom)
points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19)
points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputation summary table for na_interpolation(stine)
mad3_10missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3
rmse3_10missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3
mape3_10missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3
ioa3_10missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3
fb3_10missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3
st3_10missing = rbind(mad3_10missing, rmse3_10missing, mape3_10missing, ioa3_10missing, fb3_10missing)
st3_10missing
## [,1]
## mad3_10missing 7.89543800
## rmse3_10missing 9.04026605
## mape3_10missing 7.34814073
## ioa3_10missing 0.61075307
## fb3_10missing 0.09558818
imputeTS package; stine; 20 Missing Value (smooth)
cleandata = clean(dataset)
data = aList(cleandata)
impuGV <- naInsert(data[[4]])
t <- impuGV[,1]
x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_smooth = index(x0_smooth)
trueValue_smooth <- x_smooth[c(125:144)]
x_smooth[c(125:144)] <- NA
y_smooth[c(125:144)] <- NA
id.na <- which(is.na(x_smooth))
fit1_smooth <- na_interpolation(x_smooth, option = "stine", maxgap = Inf)
imputedValue1_smooth <- fit1_smooth[125:144]
tv1_smooth <- vector()
iv1_smooth <- vector()
sum1_smooth = 0
for (i in 1:20) {
tv1_smooth[i] = as.numeric(trueValue_smooth[i])
iv1_smooth[i] = as.numeric(imputedValue1_smooth[i])
sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i])
}
mad1_smooth = sum1_smooth/20
rmse1_smooth = rmse(tv1_smooth,iv1_smooth)
mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100
ioa1_smooth = d(iv1_smooth,tv1_smooth)
fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F)
a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth)
a
## [,1]
## mad1_smooth 1.293652422
## rmse1_smooth 1.629442466
## mape1_smooth 1.108930742
## ioa1_smooth 0.806767036
## fb1_smooth 0.002417593
#plot
plot(x0_smooth, col = "grey", main = "na_interpolation stine", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_smooth)
points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19)
points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; stine; 20 Missing Value (peak)
x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_peak = index(x0_peak)
trueValue_peak <- x_peak[c(150:169)]
x_peak[c(150:169)] <- NA
y_peak[c(150:169)] <- NA
id.na <- which(is.na(x_peak))
fit1_peak <- na_interpolation(x_peak, option = "stine", maxgap = Inf)
imputedValue1_peak <- fit1_peak[150:169]
tv1_peak <- vector()
iv1_peak <- vector()
sum1_peak = 0
for (i in 1:20) {
tv1_peak[i] = as.numeric(trueValue_peak[i])
iv1_peak[i] = as.numeric(imputedValue1_peak[i])
sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i])
}
mad1_peak = sum1_peak/20
rmse1_peak = rmse(tv1_peak,iv1_peak)
mape1_peak = MAPE(iv1_peak,tv1_peak)*100
ioa1_peak = d(iv1_peak,tv1_peak)
fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F)
b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak)
b
## [,1]
## mad1_peak 10.76726155
## rmse1_peak 13.40276267
## mape1_peak 8.83609781
## ioa1_peak 0.57023137
## fb1_peak 0.05419813
#plot
plot(x0_peak, col = "grey", main = "na_interpolation stine", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_peak)
points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19)
points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; stine; 20 Missing Value (bottom)
x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_bottom = index(x0_bottom)
trueValue_bottom <- x_bottom[c(230:249)]
x_bottom[c(230:249)] <- NA
y_bottom[c(230:249)] <- NA
id.na <- which(is.na(x_bottom))
fit1_bottom <- na_interpolation(x_bottom, option = "stine", maxgap = Inf)
imputedValue1_bottom <- fit1_bottom[230:249]
tv1_bottom <- vector()
iv1_bottom <- vector()
sum1_bottom = 0
for (i in 1:20) {
tv1_bottom[i] = as.numeric(trueValue_bottom[i])
iv1_bottom[i] = as.numeric(imputedValue1_bottom[i])
sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i])
}
mad1_bottom = sum1_bottom/20
rmse1_bottom = rmse(tv1_bottom,iv1_bottom)
mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100
ioa1_bottom = d(iv1_bottom,tv1_bottom)
fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F)
c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom)
c
## [,1]
## mad1_bottom 13.9730472
## rmse1_bottom 17.3165904
## mape1_bottom 18.2794351
## ioa1_bottom 0.4574661
## fb1_bottom 0.1515399
#plot
plot(x0_bottom, col = "grey", main = "na_interpolation stine", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_bottom)
points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19)
points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputation summary table for na_interpolation(stine)
mad3_20missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3
rmse3_20missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3
mape3_20missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3
ioa3_20missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3
fb3_20missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3
st3_20missing = rbind(mad3_20missing, rmse3_20missing, mape3_20missing, ioa3_20missing, fb3_20missing)
st3_20missing
## [,1]
## mad3_20missing 8.6779871
## rmse3_20missing 10.7829319
## mape3_20missing 9.0872063
## ioa3_20missing 0.6114882
## fb3_20missing 0.1018325
| imputeTS package; stine; 30 Missing Value (smooth) |
| ```r cleandata = clean(dataset) data = aList(cleandata) impuGV <- naInsert(data[[4]]) t <- impuGV[,1] x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)] t1_smooth = index(x0_smooth) |
| trueValue_smooth <- x_smooth[c(120:149)] x_smooth[c(120:149)] <- NA y_smooth[c(120:149)] <- NA id.na <- which(is.na(x_smooth)) |
| fit1_smooth <- na_interpolation(x_smooth, option = “stine”, maxgap = Inf) imputedValue1_smooth <- fit1_smooth[120:149] tv1_smooth <- vector() iv1_smooth <- vector() sum1_smooth = 0 for (i in 1:30) { tv1_smooth[i] = as.numeric(trueValue_smooth[i]) iv1_smooth[i] = as.numeric(imputedValue1_smooth[i]) sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i]) } mad1_smooth = sum1_smooth/30 rmse1_smooth = rmse(tv1_smooth,iv1_smooth) mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100 ioa1_smooth = d(iv1_smooth,tv1_smooth) fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F) a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth) a ``` |
## [,1] ## mad1_smooth 7.24272529 ## rmse1_smooth 8.08703420 ## mape1_smooth 6.28557420 ## ioa1_smooth 0.55342912 ## fb1_smooth 0.06135714 |
r #plot plot(x0_smooth, col = "grey", main = "na_interpolation stine", xlab = "DisplayTime", ylab = "GlucoseValue") lines(x_smooth) points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19) points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17) legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17)) |
| ```r x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)] t1_peak = index(x0_peak) |
| trueValue_peak <- x_peak[c(145:174)] x_peak[c(145:174)] <- NA y_peak[c(145:174)] <- NA id.na <- which(is.na(x_peak)) |
| fit1_peak <- na_interpolation(x_peak, option = “stine”, maxgap = Inf) imputedValue1_peak <- fit1_peak[145:174] tv1_peak <- vector() iv1_peak <- vector() sum1_peak = 0 for (i in 1:30) { tv1_peak[i] = as.numeric(trueValue_peak[i]) iv1_peak[i] = as.numeric(imputedValue1_peak[i]) sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i]) } mad1_peak = sum1_peak/30 rmse1_peak = rmse(tv1_peak,iv1_peak) mape1_peak = MAPE(iv1_peak,tv1_peak)*100 ioa1_peak = d(iv1_peak,tv1_peak) fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F) b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak) b ``` |
## [,1] ## mad1_peak 8.633263846 ## rmse1_peak 10.348044958 ## mape1_peak 7.470560577 ## ioa1_peak 0.484408929 ## fb1_peak 0.002071825 |
r #plot plot(x0_peak, col = "grey", main = "na_interpolation stine", xlab = "DisplayTime", ylab = "GlucoseValue") lines(x_peak) points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19) points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17) legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17)) |
| ```r x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)] t1_bottom = index(x0_bottom) |
| trueValue_bottom <- x_bottom[c(225:254)] x_bottom[c(225:254)] <- NA y_bottom[c(225:254)] <- NA id.na <- which(is.na(x_bottom)) |
| fit1_bottom <- na_interpolation(x_bottom, option = “stine”, maxgap = Inf) imputedValue1_bottom <- fit1_bottom[225:254] tv1_bottom <- vector() iv1_bottom <- vector() sum1_bottom = 0 for (i in 1:30) { tv1_bottom[i] = as.numeric(trueValue_bottom[i]) iv1_bottom[i] = as.numeric(imputedValue1_bottom[i]) sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i]) } mad1_bottom = sum1_bottom/30 rmse1_bottom = rmse(tv1_bottom,iv1_bottom) mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100 ioa1_bottom = d(iv1_bottom,tv1_bottom) fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F) c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom) c ``` |
## [,1] ## mad1_bottom 14.3452672 ## rmse1_bottom 17.9085494 ## mape1_bottom 17.9363106 ## ioa1_bottom 0.4084138 ## fb1_bottom 0.1455043 |
r #plot plot(x0_bottom, col = "grey", main = "na_interpolation stine", xlab = "DisplayTime", ylab = "GlucoseValue") lines(x_bottom) points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19) points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17) legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17)) |
r mad3_30missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3 rmse3_30missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3 mape3_30missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3 ioa3_30missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3 fb3_30missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3 st3_30missing = rbind(mad3_30missing, rmse3_30missing, mape3_30missing, ioa3_30missing, fb3_30missing) st3_30missing |
## [,1] ## mad3_30missing 10.0737521 ## rmse3_30missing 12.1145428 ## mape3_30missing 10.5548947 ## ioa3_30missing 0.4820840 ## fb3_30missing 0.1174553 |
imputeTS package; na_kalman; 5 Missing Value (smooth)
cleandata = clean(dataset)
data = aList(cleandata)
impuGV <- naInsert(data[[4]])
t <- impuGV[,1]
x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_smooth = index(x0_smooth)
trueValue_smooth <- x_smooth[c(131:135)]
x_smooth[c(131:135)] <- NA
y_smooth[c(131:135)] <- NA
id.na <- which(is.na(x_smooth))
fit1_smooth <- na_kalman(x_smooth, model = "StructTS", smooth = TRUE)
imputedValue1_smooth <- fit1_smooth[131:135]
tv1_smooth <- vector()
iv1_smooth <- vector()
sum1_smooth = 0
for (i in 1:5) {
tv1_smooth[i] = as.numeric(trueValue_smooth[i])
iv1_smooth[i] = as.numeric(imputedValue1_smooth[i])
sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i])
}
mad1_smooth = sum1_smooth/5
rmse1_smooth = rmse(tv1_smooth,iv1_smooth)
mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100
ioa1_smooth = d(iv1_smooth,tv1_smooth)
fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F)
a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth)
a
## [,1]
## mad1_smooth 1.800000000
## rmse1_smooth 2.489979920
## mape1_smooth 1.576135803
## ioa1_smooth 0.537313433
## fb1_smooth 0.008583691
#plot
plot(x0_smooth, col = "grey", main = "na_kalman", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_smooth)
points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19)
points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; na_kalman; 5 Missing Value (peak)
x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_peak = index(x0_peak)
trueValue_peak <- x_peak[c(157:161)]
x_peak[c(157:161)] <- NA
y_peak[c(157:161)] <- NA
id.na <- which(is.na(x_peak))
fit1_peak <- na_kalman(x_smooth, model = "StructTS", smooth = TRUE)
imputedValue1_peak <- fit1_peak[157:161]
tv1_peak <- vector()
iv1_peak <- vector()
sum1_peak = 0
for (i in 1:5) {
tv1_peak[i] = as.numeric(trueValue_peak[i])
iv1_peak[i] = as.numeric(imputedValue1_peak[i])
sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i])
}
mad1_peak = sum1_peak/5
rmse1_peak = rmse(tv1_peak,iv1_peak)
mape1_peak = MAPE(iv1_peak,tv1_peak)*100
ioa1_peak = d(iv1_peak,tv1_peak)
fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F)
b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak)
b
## [,1]
## mad1_peak 0
## rmse1_peak 0
## mape1_peak 0
## ioa1_peak 1
## fb1_peak 0
#plot
plot(x0_peak, col = "grey", main = "na_kalman", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_peak)
points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19)
points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; na_kalman; 5 Missing Value (bottom)
x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_bottom = index(x0_bottom)
trueValue_bottom <- x_bottom[c(235:239)]
x_bottom[c(235:239)] <- NA
y_bottom[c(235:239)] <- NA
id.na <- which(is.na(x_bottom))
fit1_bottom <- na_kalman(x_smooth, model = "StructTS", smooth = TRUE)
imputedValue1_bottom <- fit1_bottom[235:239]
tv1_bottom <- vector()
iv1_bottom <- vector()
sum1_bottom = 0
for (i in 1:5) {
tv1_bottom[i] = as.numeric(trueValue_bottom[i])
iv1_bottom[i] = as.numeric(imputedValue1_bottom[i])
sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i])
}
mad1_bottom = sum1_bottom/5
rmse1_bottom = rmse(tv1_bottom,iv1_bottom)
mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100
ioa1_bottom = d(iv1_bottom,tv1_bottom)
fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F)
c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom)
c
## [,1]
## mad1_bottom 0
## rmse1_bottom 0
## mape1_bottom 0
## ioa1_bottom 1
## fb1_bottom 0
#plot
plot(x0_bottom, col = "grey", main = "na_kalman", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_bottom)
points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19)
points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputation summary table for na_kalman
mad4_5missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3
rmse4_5missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3
mape4_5missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3
ioa4_5missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3
fb4_5missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3
st4_5missing = rbind(mad4_5missing, rmse4_5missing, mape4_5missing, ioa4_5missing, fb4_5missing)
st4_5missing
## [,1]
## mad4_5missing 0.60000000
## rmse4_5missing 0.82999331
## mape4_5missing 0.52537860
## ioa4_5missing 0.84577114
## fb4_5missing 0.00286123
imputeTS package; na_kalman; 10 Missing Value (smooth)
cleandata = clean(dataset)
data = aList(cleandata)
impuGV <- naInsert(data[[4]])
t <- impuGV[,1]
x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_smooth = index(x0_smooth)
trueValue_smooth <- x_smooth[c(131:140)]
x_smooth[c(131:140)] <- NA
y_smooth[c(131:140)] <- NA
id.na <- which(is.na(x_smooth))
fit1_smooth <- na_kalman(x_smooth, model = "StructTS", smooth = TRUE)
imputedValue1_smooth <- fit1_smooth[131:140]
tv1_smooth <- vector()
iv1_smooth <- vector()
sum1_smooth = 0
for (i in 1:10) {
tv1_smooth[i] = as.numeric(trueValue_smooth[i])
iv1_smooth[i] = as.numeric(imputedValue1_smooth[i])
sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i])
}
mad1_smooth = sum1_smooth/10
rmse1_smooth = rmse(tv1_smooth,iv1_smooth)
mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100
ioa1_smooth = d(iv1_smooth,tv1_smooth)
fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F)
a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth)
a
## [,1]
## mad1_smooth 1.572727273
## rmse1_smooth 1.923538406
## mape1_smooth 1.338510711
## ioa1_smooth 0.692440226
## fb1_smooth 0.007695596
#plot
plot(x0_smooth, col = "grey", main = "na_kalman", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_smooth)
points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19)
points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; na_kalman; 10 Missing Value (peak)
x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_peak = index(x0_peak)
trueValue_peak <- x_peak[c(155:164)]
x_peak[c(155:164)] <- NA
y_peak[c(155:164)] <- NA
id.na <- which(is.na(x_peak))
fit1_peak <- na_kalman(x_smooth, model = "StructTS", smooth = TRUE)
imputedValue1_peak <- fit1_peak[155:164]
tv1_peak <- vector()
iv1_peak <- vector()
sum1_peak = 0
for (i in 1:10) {
tv1_peak[i] = as.numeric(trueValue_peak[i])
iv1_peak[i] = as.numeric(imputedValue1_peak[i])
sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i])
}
mad1_peak = sum1_peak/10
rmse1_peak = rmse(tv1_peak,iv1_peak)
mape1_peak = MAPE(iv1_peak,tv1_peak)*100
ioa1_peak = d(iv1_peak,tv1_peak)
fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F)
b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak)
b
## [,1]
## mad1_peak 0
## rmse1_peak 0
## mape1_peak 0
## ioa1_peak 1
## fb1_peak 0
#plot
plot(x0_peak, col = "grey", main = "na_kalman", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_peak)
points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19)
points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; na_kalman; 10 Missing Value (bottom)
x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_bottom = index(x0_bottom)
trueValue_bottom <- x_bottom[c(234:243)]
x_bottom[c(234:243)] <- NA
y_bottom[c(234:243)] <- NA
id.na <- which(is.na(x_bottom))
fit1_bottom <- na_kalman(x_smooth, model = "StructTS", smooth = TRUE)
imputedValue1_bottom <- fit1_bottom[234:243]
tv1_bottom <- vector()
iv1_bottom <- vector()
sum1_bottom = 0
for (i in 1:10) {
tv1_bottom[i] = as.numeric(trueValue_bottom[i])
iv1_bottom[i] = as.numeric(imputedValue1_bottom[i])
sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i])
}
mad1_bottom = sum1_bottom/10
rmse1_bottom = rmse(tv1_bottom,iv1_bottom)
mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100
ioa1_bottom = d(iv1_bottom,tv1_bottom)
fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F)
c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom)
c
## [,1]
## mad1_bottom 0
## rmse1_bottom 0
## mape1_bottom 0
## ioa1_bottom 1
## fb1_bottom 0
#plot
plot(x0_bottom, col = "grey", main = "na_kalman", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_bottom)
points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19)
points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputation summary table for na_kalman
mad4_10missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3
rmse4_10missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3
mape4_10missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3
ioa4_10missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3
fb4_10missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3
st4_10missing = rbind(mad4_10missing, rmse4_10missing, mape4_10missing, ioa4_10missing, fb4_10missing)
st4_10missing
## [,1]
## mad4_10missing 0.524242424
## rmse4_10missing 0.641179469
## mape4_10missing 0.446170237
## ioa4_10missing 0.897480075
## fb4_10missing 0.002565199
imputeTS package; na_kalman; 20 Missing Value (smooth)
cleandata = clean(dataset)
data = aList(cleandata)
impuGV <- naInsert(data[[4]])
t <- impuGV[,1]
x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_smooth = index(x0_smooth)
trueValue_smooth <- x_smooth[c(125:144)]
x_smooth[c(125:144)] <- NA
y_smooth[c(125:144)] <- NA
id.na <- which(is.na(x_smooth))
fit1_smooth <- na_kalman(x_smooth, model = "StructTS", smooth = TRUE)
imputedValue1_smooth <- fit1_smooth[125:144]
tv1_smooth <- vector()
iv1_smooth <- vector()
sum1_smooth = 0
for (i in 1:20) {
tv1_smooth[i] = as.numeric(trueValue_smooth[i])
iv1_smooth[i] = as.numeric(imputedValue1_smooth[i])
sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i])
}
mad1_smooth = sum1_smooth/20
rmse1_smooth = rmse(tv1_smooth,iv1_smooth)
mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100
ioa1_smooth = d(iv1_smooth,tv1_smooth)
fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F)
a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth)
a
## [,1]
## mad1_smooth 2.49285714
## rmse1_smooth 2.93622693
## mape1_smooth 2.12572968
## ioa1_smooth 0.62503068
## fb1_smooth 0.02040373
#plot
plot(x0_smooth, col = "grey", main = "na_kalman", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_smooth)
points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19)
points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; na_kalman; 20 Missing Value (peak)
x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_peak = index(x0_peak)
trueValue_peak <- x_peak[c(150:169)]
x_peak[c(150:169)] <- NA
y_peak[c(150:169)] <- NA
id.na <- which(is.na(x_peak))
fit1_peak <- na_kalman(x_smooth, model = "StructTS", smooth = TRUE)
imputedValue1_peak <- fit1_peak[150:169]
tv1_peak <- vector()
iv1_peak <- vector()
sum1_peak = 0
for (i in 1:20) {
tv1_peak[i] = as.numeric(trueValue_peak[i])
iv1_peak[i] = as.numeric(imputedValue1_peak[i])
sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i])
}
mad1_peak = sum1_peak/20
rmse1_peak = rmse(tv1_peak,iv1_peak)
mape1_peak = MAPE(iv1_peak,tv1_peak)*100
ioa1_peak = d(iv1_peak,tv1_peak)
fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F)
b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak)
b
## [,1]
## mad1_peak 0
## rmse1_peak 0
## mape1_peak 0
## ioa1_peak 1
## fb1_peak 0
#plot
plot(x0_peak, col = "grey", main = "na_kalman", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_peak)
points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19)
points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; na_kalman; 20 Missing Value (bottom)
x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_bottom = index(x0_bottom)
trueValue_bottom <- x_bottom[c(230:249)]
x_bottom[c(230:249)] <- NA
y_bottom[c(230:249)] <- NA
id.na <- which(is.na(x_bottom))
fit1_bottom <- na_kalman(x_smooth, model = "StructTS", smooth = TRUE)
imputedValue1_bottom <- fit1_bottom[230:249]
tv1_bottom <- vector()
iv1_bottom <- vector()
sum1_bottom = 0
for (i in 1:20) {
tv1_bottom[i] = as.numeric(trueValue_bottom[i])
iv1_bottom[i] = as.numeric(imputedValue1_bottom[i])
sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i])
}
mad1_bottom = sum1_bottom/20
rmse1_bottom = rmse(tv1_bottom,iv1_bottom)
mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100
ioa1_bottom = d(iv1_bottom,tv1_bottom)
fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F)
c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom)
c
## [,1]
## mad1_bottom 0
## rmse1_bottom 0
## mape1_bottom 0
## ioa1_bottom 1
## fb1_bottom 0
#plot
plot(x0_bottom, col = "grey", main = "na_kalman", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_bottom)
points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19)
points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputation summary table for na_kalman
mad4_20missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3
rmse4_20missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3
mape4_20missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3
ioa4_20missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3
fb4_20missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3
st4_20missing = rbind(mad4_20missing, rmse4_20missing, mape4_20missing, ioa4_20missing, fb4_20missing)
st4_20missing
## [,1]
## mad4_20missing 0.830952381
## rmse4_20missing 0.978742309
## mape4_20missing 0.708576559
## ioa4_20missing 0.875010226
## fb4_20missing 0.006801244
| imputeTS package; na_kalman; 30 Missing Value (smooth) |
| ```r cleandata = clean(dataset) data = aList(cleandata) impuGV <- naInsert(data[[4]]) t <- impuGV[,1] x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)] t1_smooth = index(x0_smooth) |
| trueValue_smooth <- x_smooth[c(120:149)] x_smooth[c(120:149)] <- NA y_smooth[c(120:149)] <- NA id.na <- which(is.na(x_smooth)) |
| fit1_smooth <- na_kalman(x_smooth, model = “StructTS”, smooth = TRUE) imputedValue1_smooth <- fit1_smooth[120:149] tv1_smooth <- vector() iv1_smooth <- vector() sum1_smooth = 0 for (i in 1:30) { tv1_smooth[i] = as.numeric(trueValue_smooth[i]) iv1_smooth[i] = as.numeric(imputedValue1_smooth[i]) sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i]) } mad1_smooth = sum1_smooth/30 rmse1_smooth = rmse(tv1_smooth,iv1_smooth) mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100 ioa1_smooth = d(iv1_smooth,tv1_smooth) fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F) a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth) a ``` |
## [,1] ## mad1_smooth 6.93870968 ## rmse1_smooth 7.70651170 ## mape1_smooth 6.00348397 ## ioa1_smooth 0.55028213 ## fb1_smooth 0.05869074 |
r #plot plot(x0_smooth, col = "grey", main = "na_kalman", xlab = "DisplayTime", ylab = "GlucoseValue") lines(x_smooth) points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19) points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17) legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17)) |
| ```r x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)] t1_peak = index(x0_peak) |
| trueValue_peak <- x_peak[c(145:174)] x_peak[c(145:174)] <- NA y_peak[c(145:174)] <- NA id.na <- which(is.na(x_peak)) |
| fit1_peak <- na_kalman(x_smooth, model = “StructTS”, smooth = TRUE) imputedValue1_peak <- fit1_peak[145:174] tv1_peak <- vector() iv1_peak <- vector() sum1_peak = 0 for (i in 1:30) { tv1_peak[i] = as.numeric(trueValue_peak[i]) iv1_peak[i] = as.numeric(imputedValue1_peak[i]) sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i]) } mad1_peak = sum1_peak/30 rmse1_peak = rmse(tv1_peak,iv1_peak) mape1_peak = MAPE(iv1_peak,tv1_peak)*100 ioa1_peak = d(iv1_peak,tv1_peak) fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F) b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak) b ``` |
## [,1] ## mad1_peak 0.445161290 ## rmse1_peak 1.295018337 ## mape1_peak 0.387392326 ## ioa1_peak 0.996940953 ## fb1_peak 0.002442187 |
r #plot plot(x0_peak, col = "grey", main = "na_kalman", xlab = "DisplayTime", ylab = "GlucoseValue") lines(x_peak) points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19) points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17) legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17)) |
| ```r x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)] t1_bottom = index(x0_bottom) |
| trueValue_bottom <- x_bottom[c(225:254)] x_bottom[c(225:254)] <- NA y_bottom[c(225:254)] <- NA id.na <- which(is.na(x_bottom)) |
| fit1_bottom <- na_kalman(x_smooth, model = “StructTS”, smooth = TRUE) imputedValue1_bottom <- fit1_bottom[225:254] tv1_bottom <- vector() iv1_bottom <- vector() sum1_bottom = 0 for (i in 1:30) { tv1_bottom[i] = as.numeric(trueValue_bottom[i]) iv1_bottom[i] = as.numeric(imputedValue1_bottom[i]) sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i]) } mad1_bottom = sum1_bottom/30 rmse1_bottom = rmse(tv1_bottom,iv1_bottom) mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100 ioa1_bottom = d(iv1_bottom,tv1_bottom) fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F) c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom) c ``` |
## [,1] ## mad1_bottom 0 ## rmse1_bottom 0 ## mape1_bottom 0 ## ioa1_bottom 1 ## fb1_bottom 0 |
r #plot plot(x0_bottom, col = "grey", main = "na_kalman", xlab = "DisplayTime", ylab = "GlucoseValue") lines(x_bottom) points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19) points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17) legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17)) |
r mad4_30missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3 rmse4_30missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3 mape4_30missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3 ioa4_30missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3 fb4_30missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3 st4_30missing = rbind(mad4_30missing, rmse4_30missing, mape4_30missing, ioa4_30missing, fb4_30missing) st4_30missing |
## [,1] ## mad4_30missing 2.46129032 ## rmse4_30missing 3.00051001 ## mape4_30missing 2.13029210 ## ioa4_30missing 0.84907436 ## fb4_30missing 0.01956358 |
imputeTS package; na_locf; 5 Missing Value (smooth)
cleandata = clean(dataset)
data = aList(cleandata)
impuGV <- naInsert(data[[4]])
t <- impuGV[,1]
x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_smooth = index(x0_smooth)
trueValue_smooth <- x_smooth[c(131:135)]
x_smooth[c(131:135)] <- NA
y_smooth[c(131:135)] <- NA
id.na <- which(is.na(x_smooth))
fit1_smooth <- na_locf(x_smooth, option = "locf", na_remaining = "rev", maxgap = Inf)
imputedValue1_smooth <- fit1_smooth[131:135]
tv1_smooth <- vector()
iv1_smooth <- vector()
sum1_smooth = 0
for (i in 1:5) {
tv1_smooth[i] = as.numeric(trueValue_smooth[i])
iv1_smooth[i] = as.numeric(imputedValue1_smooth[i])
sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i])
}
mad1_smooth = sum1_smooth/5
rmse1_smooth = rmse(tv1_smooth,iv1_smooth)
mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100
ioa1_smooth = d(iv1_smooth,tv1_smooth)
fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F)
a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth)
a
## [,1]
## mad1_smooth 2.4000000
## rmse1_smooth 2.8284271
## mape1_smooth 2.0488884
## ioa1_smooth 0.4444444
## fb1_smooth 0.0173913
#plot
plot(x0_smooth, col = "grey", main = "na_locf", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_smooth)
points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19)
points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; na_locf; 5 Missing Value (peak)
x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_peak = index(x0_peak)
trueValue_peak <- x_peak[c(157:161)]
x_peak[c(157:161)] <- NA
y_peak[c(157:161)] <- NA
id.na <- which(is.na(x_peak))
fit1_peak <- na_locf(x_smooth, option = "locf", na_remaining = "rev", maxgap = Inf)
imputedValue1_peak <- fit1_peak[157:161]
tv1_peak <- vector()
iv1_peak <- vector()
sum1_peak = 0
for (i in 1:5) {
tv1_peak[i] = as.numeric(trueValue_peak[i])
iv1_peak[i] = as.numeric(imputedValue1_peak[i])
sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i])
}
mad1_peak = sum1_peak/5
rmse1_peak = rmse(tv1_peak,iv1_peak)
mape1_peak = MAPE(iv1_peak,tv1_peak)*100
ioa1_peak = d(iv1_peak,tv1_peak)
fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F)
b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak)
b
## [,1]
## mad1_peak 0
## rmse1_peak 0
## mape1_peak 0
## ioa1_peak 1
## fb1_peak 0
#plot
plot(x0_peak, col = "grey", main = "na_locf", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_peak)
points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19)
points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; na_locf; 5 Missing Value (bottom)
x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_bottom = index(x0_bottom)
trueValue_bottom <- x_bottom[c(235:239)]
x_bottom[c(235:239)] <- NA
y_bottom[c(235:239)] <- NA
id.na <- which(is.na(x_bottom))
fit1_bottom <- na_locf(x_smooth, option = "locf", na_remaining = "rev", maxgap = Inf)
imputedValue1_bottom <- fit1_bottom[235:239]
tv1_bottom <- vector()
iv1_bottom <- vector()
sum1_bottom = 0
for (i in 1:5) {
tv1_bottom[i] = as.numeric(trueValue_bottom[i])
iv1_bottom[i] = as.numeric(imputedValue1_bottom[i])
sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i])
}
mad1_bottom = sum1_bottom/5
rmse1_bottom = rmse(tv1_bottom,iv1_bottom)
mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100
ioa1_bottom = d(iv1_bottom,tv1_bottom)
fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F)
c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom)
c
## [,1]
## mad1_bottom 0
## rmse1_bottom 0
## mape1_bottom 0
## ioa1_bottom 1
## fb1_bottom 0
#plot
plot(x0_bottom, col = "grey", main = "na_locf", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_bottom)
points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19)
points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputation summary table for na_locf
mad5_5missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3
rmse5_5missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3
mape5_5missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3
ioa5_5missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3
fb5_5missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3
st5_5missing = rbind(mad5_5missing, rmse5_5missing, mape5_5missing, ioa5_5missing, fb5_5missing)
st5_5missing
## [,1]
## mad5_5missing 0.800000000
## rmse5_5missing 0.942809042
## mape5_5missing 0.682962809
## ioa5_5missing 0.814814815
## fb5_5missing 0.005797101
imputeTS package; na_locf; 10 Missing Value (smooth)
cleandata = clean(dataset)
data = aList(cleandata)
impuGV <- naInsert(data[[4]])
t <- impuGV[,1]
x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_smooth = index(x0_smooth)
trueValue_smooth <- x_smooth[c(131:140)]
x_smooth[c(131:140)] <- NA
y_smooth[c(131:140)] <- NA
id.na <- which(is.na(x_smooth))
fit1_smooth <- na_locf(x_smooth, option = "locf", na_remaining = "rev", maxgap = Inf)
imputedValue1_smooth <- fit1_smooth[131:140]
tv1_smooth <- vector()
iv1_smooth <- vector()
sum1_smooth = 0
for (i in 1:10) {
tv1_smooth[i] = as.numeric(trueValue_smooth[i])
iv1_smooth[i] = as.numeric(imputedValue1_smooth[i])
sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i])
}
mad1_smooth = sum1_smooth/10
rmse1_smooth = rmse(tv1_smooth,iv1_smooth)
mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100
ioa1_smooth = d(iv1_smooth,tv1_smooth)
fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F)
a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth)
a
## [,1]
## mad1_smooth 3.60000000
## rmse1_smooth 4.02492236
## mape1_smooth 3.04000559
## ioa1_smooth 0.43037975
## fb1_smooth 0.02938634
#plot
plot(x0_smooth, col = "grey", main = "na_locf", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_smooth)
points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19)
points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; na_locf; 10 Missing Value (peak)
x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_peak = index(x0_peak)
trueValue_peak <- x_peak[c(155:164)]
x_peak[c(155:164)] <- NA
y_peak[c(155:164)] <- NA
id.na <- which(is.na(x_peak))
fit1_peak <- na_locf(x_smooth, option = "locf", na_remaining = "rev", maxgap = Inf)
imputedValue1_peak <- fit1_peak[155:164]
tv1_peak <- vector()
iv1_peak <- vector()
sum1_peak = 0
for (i in 1:10) {
tv1_peak[i] = as.numeric(trueValue_peak[i])
iv1_peak[i] = as.numeric(imputedValue1_peak[i])
sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i])
}
mad1_peak = sum1_peak/10
rmse1_peak = rmse(tv1_peak,iv1_peak)
mape1_peak = MAPE(iv1_peak,tv1_peak)*100
ioa1_peak = d(iv1_peak,tv1_peak)
fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F)
b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak)
b
## [,1]
## mad1_peak 0
## rmse1_peak 0
## mape1_peak 0
## ioa1_peak 1
## fb1_peak 0
#plot
plot(x0_peak, col = "grey", main = "na_locf", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_peak)
points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19)
points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; na_locf; 10 Missing Value (bottom)
x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_bottom = index(x0_bottom)
trueValue_bottom <- x_bottom[c(234:243)]
x_bottom[c(234:243)] <- NA
y_bottom[c(234:243)] <- NA
id.na <- which(is.na(x_bottom))
fit1_bottom <- na_locf(x_smooth, option = "locf", na_remaining = "rev", maxgap = Inf)
imputedValue1_bottom <- fit1_bottom[234:243]
tv1_bottom <- vector()
iv1_bottom <- vector()
sum1_bottom = 0
for (i in 1:10) {
tv1_bottom[i] = as.numeric(trueValue_bottom[i])
iv1_bottom[i] = as.numeric(imputedValue1_bottom[i])
sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i])
}
mad1_bottom = sum1_bottom/10
rmse1_bottom = rmse(tv1_bottom,iv1_bottom)
mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100
ioa1_bottom = d(iv1_bottom,tv1_bottom)
fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F)
c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom)
c
## [,1]
## mad1_bottom 0
## rmse1_bottom 0
## mape1_bottom 0
## ioa1_bottom 1
## fb1_bottom 0
#plot
plot(x0_bottom, col = "grey", main = "na_locf", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_bottom)
points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19)
points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputation summary table for na_locf
mad5_10missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3
rmse5_10missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3
mape5_10missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3
ioa5_10missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3
fb5_10missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3
st5_10missing = rbind(mad5_10missing, rmse5_10missing, mape5_10missing, ioa5_10missing, fb5_10missing)
st5_10missing
## [,1]
## mad5_10missing 1.200000000
## rmse5_10missing 1.341640786
## mape5_10missing 1.013335196
## ioa5_10missing 0.810126582
## fb5_10missing 0.009795448
imputeTS package; na_locf; 20 Missing Value (smooth)
cleandata = clean(dataset)
data = aList(cleandata)
impuGV <- naInsert(data[[4]])
t <- impuGV[,1]
x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_smooth = index(x0_smooth)
trueValue_smooth <- x_smooth[c(125:144)]
x_smooth[c(125:144)] <- NA
y_smooth[c(125:144)] <- NA
id.na <- which(is.na(x_smooth))
fit1_smooth <- na_locf(x_smooth, option = "locf", na_remaining = "rev", maxgap = Inf)
imputedValue1_smooth <- fit1_smooth[125:144]
tv1_smooth <- vector()
iv1_smooth <- vector()
sum1_smooth = 0
for (i in 1:20) {
tv1_smooth[i] = as.numeric(trueValue_smooth[i])
iv1_smooth[i] = as.numeric(imputedValue1_smooth[i])
sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i])
}
mad1_smooth = sum1_smooth/20
rmse1_smooth = rmse(tv1_smooth,iv1_smooth)
mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100
ioa1_smooth = d(iv1_smooth,tv1_smooth)
fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F)
a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth)
a
## [,1]
## mad1_smooth 5.3500000
## rmse1_smooth 5.8008620
## mape1_smooth 4.5627445
## ioa1_smooth 0.3747619
## fb1_smooth 0.0470640
#plot
plot(x0_smooth, col = "grey", main = "na_locf", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_smooth)
points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19)
points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; na_locf; 20 Missing Value (peak)
x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_peak = index(x0_peak)
trueValue_peak <- x_peak[c(150:169)]
x_peak[c(150:169)] <- NA
y_peak[c(150:169)] <- NA
id.na <- which(is.na(x_peak))
fit1_peak <- na_locf(x_smooth, option = "locf", na_remaining = "rev", maxgap = Inf)
imputedValue1_peak <- fit1_peak[150:169]
tv1_peak <- vector()
iv1_peak <- vector()
sum1_peak = 0
for (i in 1:20) {
tv1_peak[i] = as.numeric(trueValue_peak[i])
iv1_peak[i] = as.numeric(imputedValue1_peak[i])
sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i])
}
mad1_peak = sum1_peak/20
rmse1_peak = rmse(tv1_peak,iv1_peak)
mape1_peak = MAPE(iv1_peak,tv1_peak)*100
ioa1_peak = d(iv1_peak,tv1_peak)
fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F)
b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak)
b
## [,1]
## mad1_peak 0
## rmse1_peak 0
## mape1_peak 0
## ioa1_peak 1
## fb1_peak 0
#plot
plot(x0_peak, col = "grey", main = "na_locf", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_peak)
points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19)
points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; na_locf; 20 Missing Value (bottom)
x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_bottom = index(x0_bottom)
trueValue_bottom <- x_bottom[c(230:249)]
x_bottom[c(230:249)] <- NA
y_bottom[c(230:249)] <- NA
id.na <- which(is.na(x_bottom))
fit1_bottom <- na_locf(x_smooth, option = "locf", na_remaining = "rev", maxgap = Inf)
imputedValue1_bottom <- fit1_bottom[230:249]
tv1_bottom <- vector()
iv1_bottom <- vector()
sum1_bottom = 0
for (i in 1:20) {
tv1_bottom[i] = as.numeric(trueValue_bottom[i])
iv1_bottom[i] = as.numeric(imputedValue1_bottom[i])
sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i])
}
mad1_bottom = sum1_bottom/20
rmse1_bottom = rmse(tv1_bottom,iv1_bottom)
mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100
ioa1_bottom = d(iv1_bottom,tv1_bottom)
fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F)
c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom)
c
## [,1]
## mad1_bottom 0
## rmse1_bottom 0
## mape1_bottom 0
## ioa1_bottom 1
## fb1_bottom 0
#plot
plot(x0_bottom, col = "grey", main = "na_locf", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_bottom)
points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19)
points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputation summary table for na_locf
mad5_20missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3
rmse5_20missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3
mape5_20missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3
ioa5_20missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3
fb5_20missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3
st5_20missing = rbind(mad5_20missing, rmse5_20missing, mape5_20missing, ioa5_20missing, fb5_20missing)
st5_20missing
## [,1]
## mad5_20missing 1.7833333
## rmse5_20missing 1.9336207
## mape5_20missing 1.5209148
## ioa5_20missing 0.7915873
## fb5_20missing 0.0156880
imputeTS package; na_locf; 30 Missing Value (smooth)
cleandata = clean(dataset)
data = aList(cleandata)
impuGV <- naInsert(data[[4]])
t <- impuGV[,1]
x0_smooth <- x_smooth <- y_smooth <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_smooth = index(x0_smooth)
trueValue_smooth <- x_smooth[c(120:149)]
x_smooth[c(120:149)] <- NA
y_smooth[c(120:149)] <- NA
id.na <- which(is.na(x_smooth))
fit1_smooth <- na_locf(x_smooth, option = "locf", na_remaining = "rev", maxgap = Inf)
imputedValue1_smooth <- fit1_smooth[120:149]
tv1_smooth <- vector()
iv1_smooth <- vector()
sum1_smooth = 0
for (i in 1:30) {
tv1_smooth[i] = as.numeric(trueValue_smooth[i])
iv1_smooth[i] = as.numeric(imputedValue1_smooth[i])
sum1_smooth = sum1_smooth + abs(iv1_smooth[i]-tv1_smooth[i])
}
mad1_smooth = sum1_smooth/30
rmse1_smooth = rmse(tv1_smooth,iv1_smooth)
mape1_smooth = MAPE(iv1_smooth,tv1_smooth)*100
ioa1_smooth = d(iv1_smooth,tv1_smooth)
fb1_smooth = compute.fb(iv1_smooth,tv1_smooth,verbose = F)
a = rbind(mad1_smooth, rmse1_smooth, mape1_smooth, ioa1_smooth, fb1_smooth)
a
## [,1]
## mad1_smooth 12.2000000
## rmse1_smooth 13.0000000
## mape1_smooth 10.5437186
## ioa1_smooth 0.3424125
## fb1_smooth 0.1111111
#plot
plot(x0_smooth, col = "grey", main = "na_locf", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_smooth)
points(t1_smooth[id.na], x0_smooth[id.na], col = "blue", pch = 19)
points(t1_smooth[id.na], fit1_smooth[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; na_locf; 30 Missing Value (peak)
x0_peak <- x_peak <- y_peak <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_peak = index(x0_peak)
trueValue_peak <- x_peak[c(145:174)]
x_peak[c(145:174)] <- NA
y_peak[c(145:174)] <- NA
id.na <- which(is.na(x_peak))
fit1_peak <- na_locf(x_smooth, option = "locf", na_remaining = "rev", maxgap = Inf)
imputedValue1_peak <- fit1_peak[145:174]
tv1_peak <- vector()
iv1_peak <- vector()
sum1_peak = 0
for (i in 1:30) {
tv1_peak[i] = as.numeric(trueValue_peak[i])
iv1_peak[i] = as.numeric(imputedValue1_peak[i])
sum1_peak = sum1_peak + abs(iv1_peak[i]-tv1_peak[i])
}
mad1_peak = sum1_peak/30
rmse1_peak = rmse(tv1_peak,iv1_peak)
mape1_peak = MAPE(iv1_peak,tv1_peak)*100
ioa1_peak = d(iv1_peak,tv1_peak)
fb1_peak = compute.fb(iv1_peak,tv1_peak,verbose = F)
b = rbind(mad1_peak, rmse1_peak, mape1_peak, ioa1_peak, fb1_peak)
b
## [,1]
## mad1_peak 1.93333333
## rmse1_peak 4.85798312
## mape1_peak 1.69366813
## ioa1_peak 0.95921145
## fb1_peak 0.01714455
#plot
plot(x0_peak, col = "grey", main = "na_locf", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_peak)
points(t1_peak[id.na], x0_peak[id.na], col = "blue", pch = 19)
points(t1_peak[id.na], fit1_peak[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputeTS package; na_locf; 30 Missing Value (bottom)
x0_bottom <- x_bottom <- y_bottom <- zoo(unfactor(impuGV[,3]), t)[c(422:709)]
t1_bottom = index(x0_bottom)
trueValue_bottom <- x_bottom[c(225:254)]
x_bottom[c(225:254)] <- NA
y_bottom[c(225:254)] <- NA
id.na <- which(is.na(x_bottom))
fit1_bottom <- na_locf(x_smooth, option = "locf", na_remaining = "rev", maxgap = Inf)
imputedValue1_bottom <- fit1_bottom[225:254]
tv1_bottom <- vector()
iv1_bottom <- vector()
sum1_bottom = 0
for (i in 1:30) {
tv1_bottom[i] = as.numeric(trueValue_bottom[i])
iv1_bottom[i] = as.numeric(imputedValue1_bottom[i])
sum1_bottom = sum1_bottom + abs(iv1_bottom[i]-tv1_bottom[i])
}
mad1_bottom = sum1_bottom/30
rmse1_bottom = rmse(tv1_bottom,iv1_bottom)
mape1_bottom = MAPE(iv1_bottom,tv1_bottom)*100
ioa1_bottom = d(iv1_bottom,tv1_bottom)
fb1_bottom = compute.fb(iv1_bottom,tv1_bottom,verbose = F)
c = rbind(mad1_bottom, rmse1_bottom, mape1_bottom, ioa1_bottom, fb1_bottom)
c
## [,1]
## mad1_bottom 0
## rmse1_bottom 0
## mape1_bottom 0
## ioa1_bottom 1
## fb1_bottom 0
#plot
plot(x0_bottom, col = "grey", main = "na_locf", xlab = "DisplayTime", ylab = "GlucoseValue")
lines(x_bottom)
points(t1_bottom[id.na], x0_bottom[id.na], col = "blue", pch = 19)
points(t1_bottom[id.na], fit1_bottom[id.na], col = "red", pch = 17)
legend("topright", legend = c("true values", "imputed values"), col = c("blue", "red"), pch = c(19,17))
imputation summary table for na_locf
mad5_30missing = (mad1_smooth + mad1_peak + mad1_bottom) / 3
rmse5_30missing = (rmse1_smooth + rmse1_peak + rmse1_bottom) / 3
mape5_30missing = (mape1_smooth + mape1_peak + rmse1_bottom) / 3
ioa5_30missing = (ioa1_smooth + ioa1_bottom + ioa1_peak) / 3
fb5_30missing = (fb1_smooth + fb1_bottom + fb1_bottom) / 3
st5_30missing = rbind(mad5_30missing, rmse5_30missing, mape5_30missing, ioa5_30missing, fb5_30missing)
st5_30missing
## [,1]
## mad5_30missing 4.71111111
## rmse5_30missing 5.95266104
## mape5_30missing 4.07912891
## ioa5_30missing 0.76720797
## fb5_30missing 0.03703704
imputation summary table for imputeTS package
impuSumTable_st1 = data.frame(st1_5missing,st1_10missing,st1_20missing,st1_30missing)
impuSumTable_st2 = data.frame(st2_5missing,st2_10missing,st2_20missing,st2_30missing)
impuSumTable_st3 = data.frame(st3_5missing,st3_10missing,st3_20missing,st3_30missing)
impuSumTable_st4 = data.frame(st4_5missing,st4_10missing,st4_20missing,st4_30missing)
impuSumTable_st5 = data.frame(st5_5missing,st5_10missing,st5_20missing,st5_30missing)
impuSumTable = data.frame(impuSumTable_st1,impuSumTable_st2,impuSumTable_st3,impuSumTable_st4,impuSumTable_st5)